package com.example.api.controller;

import com.example.api.aspect.SystemControllerLog;
import com.example.api.model.entity.Sale;
import com.example.api.model.enums.ActionTypeEnum;
import com.example.api.model.support.RespBean;
import com.example.api.service.SaleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = "销售管理")
@RestController
@RequestMapping("/api/sale")
public class SaleController {

    @Resource
    private SaleService saleService;

    @ApiOperation("添加销售")
    @PostMapping("/")
    @SystemControllerLog(description = "查询角色列表", actionType = ActionTypeEnum.CREATE)
    public RespBean save(@RequestBody Sale sale) {
        return saleService.save(sale);
    }

    @ApiOperation("查询销售")
    @GetMapping("/")
    @SystemControllerLog(description = "查询角色列表", actionType = ActionTypeEnum.QUERY)
    public List<Sale> findAll(String name) {
        return saleService.findAll(name);
    }

    @ApiOperation("更新销售")
    @PutMapping("/")
    @SystemControllerLog(description = "查询角色列表", actionType = ActionTypeEnum.UPDATE)
    public RespBean update(@RequestBody Sale sale) {
        return saleService.update(sale);
    }

}